package guopai.android.outfieldcheck;


import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class AutoListActivity extends Activity {
		
	private ListView elv = null;
	private Menu mMenu;

	private static class AutoListAdapter extends BaseAdapter {

		private LayoutInflater mInflater;
		public AutoListAdapter(Context context) {
			super();
			mInflater = LayoutInflater.from(context);
			// TODO Auto-generated constructor stub
		}

		@Override
		public int getCount() {
			// TODO Auto-generated method stub
			return V_autoNumber.length;
		}

		@Override
		public Object getItem(int arg0) {
			// TODO Auto-generated method stub
			return arg0;
		}

		@Override
		public long getItemId(int position) {
			// TODO Auto-generated method stub
			return position;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			// TODO Auto-generated method stub
			ViewHolder holder;
            if (convertView == null) {
                convertView = mInflater.inflate(R.layout.autolist_sub, null);

                // Creates a ViewHolder and store references to the two children views
                // we want to bind data to.
                holder = new ViewHolder();
                holder.autoNumber = (TextView) convertView.findViewById(R.id.autonumber);
                holder.checkstatus = (TextView) convertView.findViewById(R.id.checkstatus);

                convertView.setTag(holder);
            } else {
                // Get the ViewHolder back to get fast access to the TextView
                // and the ImageView.
                holder = (ViewHolder) convertView.getTag();
            }

            // Bind the data efficiently with the holder.
            holder.autoNumber.setText(V_autoNumber[position]);
            holder.checkstatus.setText(V_checkStatus[position]);

            return convertView;
		}
		
        static class ViewHolder {
            TextView autoNumber;
            TextView checkstatus;
        }
	}
	

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.autolist);
		elv = (ListView)findViewById(R.id.autolist_sub);
		elv.setAdapter(new AutoListAdapter(this));
		

	}
	
    @Override
	public boolean onCreateOptionsMenu(Menu menu) {
        // Hold on to this
        mMenu = menu;
        
        // Inflate the currently selected menu XML resource.
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.menu1, menu);   
        return true;
    }
	
    private static final String[] V_autoNumber = {"600111", "600123"};
    private static final String[] V_checkStatus={"通过", "待检"};
	

}
